package ru.ifmo.rybakov.muclumon;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Database {
	private EntityManagerFactory entityFactory;
	
	private static Database instance = null;
	
	public static final String MUCLUMON_PERSISTENCE_UNIT = "muclumon";
	
	private Database() {
		entityFactory = Persistence.createEntityManagerFactory(MUCLUMON_PERSISTENCE_UNIT);
	}
	
	public static synchronized Database getInstance() {
		if (instance == null) {
			instance = new Database();
		}
		return instance;
	}
	
	public static EntityManagerFactory getEntityManagerFactory() {
		return getInstance().entityFactory;
	}
}
